-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exporter/*: eliminate use of .Append() #3861
exporter/*: eliminate use of .Append() #3861
Conversation
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
@@ -283,7 +284,8 @@ func TestPushFailedBatch(t *testing.T) { | |||
log := logs.ResourceLogs().At(0) | |||
|
|||
for i := 0; i < maxBufferSize; i++ { | |||
logs.ResourceLogs().Append(log) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it me, or is the removal of Append going to complicate the API for the consumers? One call is now two calls (AppendEmpty + CopyTo).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We changed to this to not change too much in components, but normally consumers should call AppendEmpty then fill the result instead of returning a metric.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand. Previously, a consumer would call:
logs.Append(log)
Now, they need to do this:
tgt := logs.AppendEmpty()
log.CopyTo(tgt)
This does complicate the caller, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually just in this case, Append was not correctly used. Because Append does not do a Copy of the log, so all the entries would point to the same log internal (a.k.a if you change one of the entry it changes all).
But in general the previous use-case was:
log := generateLog()
logs.Append(log)
Now customers will do:
log := fillLog(logs.AppendEmpty())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this one was also used incorrectly then?
From:
s.Events().Append(event)
To:
tgt := s.Events().AppendEmpty()
event.CopyTo(tgt)
If so, the change looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was, but to limit the amount of changes we went the simple path.
…tor-contrib into feat/remove_append/exporter
Description: Removes use of deprecated .Append() methods.
Link to tracking Issue: open-telemetry/opentelemetry-collector#2488